<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //构造函数  不需要return就可以返回结果
    // function Star(uname,age,sex){
    //     this.name = uname;
    //     this.age = age;
    //     this.sex = sex;
    //     this.sing = function(sang){
    //         console.log(sang);
    //     }
    // }
    // var ldh= new Star('刘德华','18岁','男');
    // console.log(ldh.age);
    // ldh.sing('冰雨');

    function King(name,type,blood){
        this.name= name;
        this.type = type;
        this.blood = blood;
        this.attack = function att(attack1){
            console.log(attack1);
        }   
    }
    var lp = new King('廉颇','力量型','500血量');
    var hy = new King('后裔','射手型','100血量');
    console.log(lp.type);
    console.log(hy.type);
    lp.attack('近战');
    hy.attack('远程');
</script>
<body>
    
</body>
</html>